package com.original.simuladoresws.controller;

import java.util.List;

import org.springframework.stereotype.Controller;

import com.original.simuladoresws.entities.TbProduct;
import com.original.simuladoresws.entities.soap.SOAPFixedIncomeComparsionsGetListInput;
import com.original.simuladoresws.entities.soap.SOAPFixedIncomeComparsionsGetListOutput;
import com.original.simuladoresws.service.ProductService;
import com.original.simuladoresws.service.impl.ProductServiceImpl;

@Controller
public class FixedIncomeComparsionsGetListController {
	ProductService productService = new ProductServiceImpl();
	
	public SOAPFixedIncomeComparsionsGetListOutput fixedIncomeComparsionsGetList(SOAPFixedIncomeComparsionsGetListInput input) {
		SOAPFixedIncomeComparsionsGetListOutput output = new SOAPFixedIncomeComparsionsGetListOutput();
		List<TbProduct> products = productService.fixedIncomeComparsionsGetList();
		try {
			int size = products.size();
			output.setError(false);
			output.setMessage("");
			output.setComparsions(products);
			output.setCurrent_page(input.getPag_CurrentPage());
			output.setTotal_items(size);
			output.setTotal_pages(size / input.getPag_Items() + 1);
			
		} catch (Exception e) {
			output.setError(true);
			output.setMessage("");
		}
		return output;
	}
}
